package com.it.service.impl;


import com.it.entity.ExamPaper;
import com.it.mapper.ExamPaperMapper;
import com.it.service.IExamPaperService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2023-09-27
 */
@Service
public class ExamPaperServiceImpl implements IExamPaperService {

    @Resource
    ExamPaperMapper examPaperMapper;
    @Override
    public Map<String, String> getExamPaperAnswers(long examId) {
        Map<String, String> trueAnswers = new HashMap<>();
        List<ExamPaper> examPaper = examPaperMapper.getExamPaper(examId);
        examPaper.forEach(question-> trueAnswers.put(Long.toString(question.getQuestionId()),question.getTrueAnswer()));
        return trueAnswers;
    }

    @Override
    public void addExamPaper(ExamPaper examPaper) {
        examPaperMapper.addExamPaper(examPaper);
    }
}
